<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/icons-extra.css" />
		<link rel="stylesheet" type="text/css" href="../css/my-modify.css" />

	</head>

	<body>
		<div class="mui-page">
			<div class="mui-navbar-inner mui-bar mui-bar-nav">
				<a class="mui-left mui-action-back mui-btn mui-btn-link mui-btn-nav mui-pull-left">
					<span class="mui-icon mui-icon-left-nav" style="width: 45px;"></span>
				</a>
				<h1 class="mui-title">修改密码</h1>
				<!--<a href="javascrip:;" id="btnModify"  class="mui-icon mui-pull-right" style="font-size: 16px; color: #000; line-height: 28px; padding-right: 15px;">修改</a>-->
			</div>
			<div class="mui-content" style="padding-top: 44px;" id="mui-content">
				<form class="mui-input-group">
					<div class="mui-content-padded" style="padding-top: 20px;">
					</div>
					<div class="mui-input-row">
						<label>原密码</label>
						<input type="password" id='fpassword' class="mui-input mui-input-password" v-model="oldpwd" placeholder="请输入原密码">
					</div>
					<div class="mui-input-row">
						<label>新密码</label>
						<input type="password" id='spassword' class="mui-input mui-input-password" v-model="newpwd1" placeholder="请输入新密码" />
					</div>
					<div class="mui-input-row">
						<label></label>
						<input type="password" id='tpassword' class="mui-input mui-input-password" v-model="newpwd2" placeholder="请再次输入新密码">
					</div>
					<div class="mui-content-padded" style="padding-top: 20px;">

					</div>
					<div class="mui-button-row">
						<button type="button" class="mui-btn mui-btn-primary" @click='updatepwd(oldpwd,newpwd1,newpwd2)'> 确认 </button>
						<button type="reset" class="mui-btn mui-btn-danger"> 重 置 </button>
					</div>
					<div class="mui-content-padded" style="padding-bottom: 20px;">
					</div>
			</div>
	</body>

</html>
<script type="text/javascript" src="../js/mui.min.js"></script>
<script type="text/javascript" src="../js/config.js"></script>
<script type="text/javascript" src="../js/localStorage.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/vue.min.js"></script>
<script type="text/javascript">
	mui.init();

	var vm = new Vue({
		el: "#mui-content",
		data: {
			oldpwd: '',
			newpwd1: '',
			newpwd2: '',

		},
		methods: {
			updatepwd: function(pwd1, pwd2, pwd3) {
				if(!pwd1) {
					mui.toast('原密码不能为空');
					return;
				}
				if(!pwd2) {
					mui.toast('新密码不能为空');
					return;
				}
				if(!pwd3) {
					mui.toast('确认密码不能为空');
					return;
				}
				if(pwd2 != pwd3) {
					mui.toast('两次输入的密码不一致');
					return;
				}

				ctdj.user.updatePassword(pwd1, pwd3, function(r) {
					if(r.success) {
						mui.toast('密码修改成功');
						setInterval(function() {
							mui.back();
						}, 500);
					} else {
						vm.oldpwd = '';
						vm.newpwd1 = '';
						vm.newpwd2 = '';
					}
				})

			}
		}
	})
</script>